package com.tarena.demo.luban.all.main.controller;

import com.tarena.demo.luban.all.main.service.ICartService;
import com.tarena.demo.luban.commons.restful.JsonResult;
import com.tarena.demo.luban.protocol.cart.param.CartAddParam;
import com.tarena.demo.luban.protocol.cart.param.CartDeleteParam;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/base/cart")
@Api(tags = "购物车")
public class CartController {

    @Autowired
    ICartService cartService;

    @PostMapping("/add")
    public JsonResult add(CartAddParam cartAddParam){
        cartService.addCart(cartAddParam);
        return JsonResult.ok("添加购物车成功！");
    }

    @PostMapping("/delete")
    public JsonResult delete(CartDeleteParam cartDeleteParam){
        cartService.deleteCart(cartDeleteParam);
        return JsonResult.ok("删除物品成功！");
    }
}
